package org.kojo.tdrm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;


@PersistenceCapable(detachable="true")
public class Task implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final int COMPLETED=0;
	public static final int ONGOING=1;
	public static final int TIMEOUT=2;
	//
	public static final int CRITICAL=1;
	public static final int NORMAL=2;
	public static final int LOW=3;
	//
	public static final int ONE_TIME = 0;
	public static final int DAILY = 1;
	public static final int MONTHLY = 2;
	
	
	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String name;
	@Persistent
	private Date dueDate;
	@Persistent
	private String note;
	@Persistent
	private Date lastUpdate;
	@Persistent
	private int state;
	@Persistent
	private int priority;
	@Persistent
	private int repeatType = 0;
	@Persistent
	private int repeatEvery = 0;
	
	@Persistent
	private User ownedUser;
	
	public Task(String name2, Date dueDate2, String note2) {
		this.name = name2;
		this.dueDate = dueDate2;
		this.note = note2;
	}
	public Task() {
		
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Date getDueDate() {
		return dueDate;
	}
	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}
	public Date getLastUpdate() {
		return lastUpdate;
	}
	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	public void setKey(Key key){
		this.key = key;
	}
	public Key getKey() {
		return key;
	}
	public String getOwnedUserId(){
		return this.ownedUser.getName();
	}
	public void setOwnedUser(User user) {
		this.ownedUser = user;
	}
	public int getPriority() {
		return priority;
	}
	/**
	 * Set Task Priority
	 * 1:Critical
	 * 2:Normal
	 * 3:Low
	 * 
	 * @param priority
	 */
	public void setPriority(int priority) {
		this.priority = priority;
	}
	public int getRepeatType() {
		return repeatType;
	}
	
	/**
	 * Type of repeat
	 * 0:ONE-TIME
	 * 1:DAILY
	 * 2:MONTHLY
	 * 
	 * @param repeatType
	 */
	public void setRepeatType(int repeatType) {
		this.repeatType = repeatType;
	}
	public int getRepeatEvery() {
		return repeatEvery;
	}
	public void setRepeatEvery(int repeatEvery) {
		this.repeatEvery = repeatEvery;
	}
	
}
